const redis = require('redis')
const bluebird = require('bluebird')
const env = require('./env')
const log = require('./log').log

bluebird.promisifyAll(redis.RedisClient.prototype)
bluebird.promisifyAll(redis.Multi.prototype)
client = redis.createClient(env.redis)

client.on("error", (err) => {
  log(err, 'error')
  console.log(err);
});
client.on("reconnecting", function () {
  console.log("********** Redis is reconnecting **********")
});
client.on("connect", () => {
  console.log("********** Redis connect succeed **********")
});

module.exports = client